package com.sprite.support.wechat.utils.model;

public class Oauth2AccessToken{
	private String appId;
	private String accessToken;
	private String openId;
	private String refreshToken;
	private String scope;
	private long expiresIn;
	private long refreshTime;
	
	public Oauth2AccessToken(String appId) {
		this.appId = appId;
	}
	public String getAppId() {
		return appId;
	}
	public void setAppId(String appId) {
		this.appId = appId;
	}
	public String getAccessToken() {
		return accessToken;
	}
	public void setAccessToken(String accessToken) {
		this.accessToken = accessToken;
	}
	public String getOpenId() {
		return openId;
	}
	public void setOpenId(String openId) {
		this.openId = openId;
	}
	public String getRefreshToken() {
		return refreshToken;
	}
	public void setRefreshToken(String refreshToken) {
		this.refreshToken = refreshToken;
	}
	public long getExpiresIn() {
		return expiresIn;
	}
	public void setExpiresIn(long expiresIn) {
		this.expiresIn = expiresIn;
	}
	public long getRefreshTime() {
		return refreshTime;
	}
	public void setRefreshTime(long refreshTime) {
		this.refreshTime = refreshTime;
	}
	
	public String getScope() {
		return scope;
	}
	public void setScope(String scope) {
		this.scope = scope;
	}
	public boolean isExpired() {
		return System.currentTimeMillis() - refreshTime + 1000 > expiresIn;
	}
	
	public void refresh(String accessToken,String refreshToken, long expiresIn) {
		refreshTime = System.currentTimeMillis();
		this.accessToken = accessToken;
		this.expiresIn = expiresIn;
		this.refreshToken = refreshToken;
	}
}
